/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package axisandallies;

import java.nio.FloatBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.util.vector.Matrix4f;
import org.lwjgl.util.vector.Vector3f;
import shapes.Square;

/**
 *
 * @author ctuchsch
 */
public class Board
{

    private Square board;
    private Matrix4f modelMatrix = null;
    private Vector3f modelPos = null;
    private Vector3f modelAngle = null;
    private Vector3f modelScale = null;
    private FloatBuffer matrix44Buffer;

    public Board()
    {
        board = new Square(0, -1f, 0f, 20, 10, 0);
        modelPos = new Vector3f(0,0,1);
        modelAngle = new Vector3f(1,1,1);
        modelScale = new Vector3f(1,1,1);
        matrix44Buffer = BufferUtils.createFloatBuffer(16);
        modelMatrix = new Matrix4f();
    }

    public float[] toFloatBuffer()
    {
        return board.toFloatArray();
    }

    public int numVertex()
    {
        return board.getNumVerts();
    }

    public byte[] getIndices()
    {
        return board.getIndexBuffer();
    }

    public int getIndicesCount()
    {
        return board.getIndicesCount();
    }

    public void applyTranslations()
    {
        modelMatrix = new Matrix4f();
        Matrix4f.scale(modelScale, modelMatrix, modelMatrix);
        Matrix4f.translate(modelPos, modelMatrix, modelMatrix);
      //  Matrix4f.rotate(200, new Vector3f(1,0,0), modelMatrix, modelMatrix);
    }
    
    public FloatBuffer getModelMatrix()
    {
        modelMatrix.store(matrix44Buffer);
        matrix44Buffer.flip();
        return matrix44Buffer;
    }
}
